package com.uidp.domain;

import java.util.List;

import com.acsior.dac.exeption.DataAccessException;
import com.acsior.sbc.exception.BusinessException;
import com.acsior.sbc.exception.SearchException;
import com.acsior.sbc.exception.ValidationException;
import com.acsior.sbc.impl.hibernate.HibernateBusinessObject;
import com.uidp.hibernatelayer.AttributeTypeDAO;
import com.uidp.hibernatelayer.AttributeTypeVO;
import com.uidp.search.AttributeTypeSearch;

public class AttributeType extends
		HibernateBusinessObject<AttributeTypeVO, AttributeTypeDAO> {

	/**
	 * Търсене на активен потребител по потребителско име
	 * 
	 * @param username
	 *            - потребителско име
	 * @return IUser - резултат
	 * 
	 * @throws BusinessException
	 * @throws SearchException
	 */
	public static List<AttributeType> searchAttributes(String label)
			throws BusinessException, SearchException {
		AttributeTypeSearch search = new AttributeTypeSearch(label);
		search.execute();

		if (search.getResult().isEmpty()) {
			// throw new BusinessException(GROUP_NAME_NOT_FOUND, username);
		}

		return search.getResult();
	}

	private String attributeName;
	private String description;
	private String label;

	public AttributeType() throws BusinessException {
		super();
	}

	public AttributeType(AttributeTypeVO h) throws BusinessException {
		super(h);
	}

	/** @see PersistentObject#initialize() */
	@Override
	protected void initialize() throws BusinessException {
		super.initialize();
	}

	@Override
	protected void setValues(AttributeTypeVO h) throws DataAccessException {
		h.setAttributeName(getAttributeName());
		h.setDescription(getDescription());
		h.setLabel(getLabel());

	}

	@Override
	protected void copyProperties(AttributeTypeVO d, boolean deepCopy)
			throws BusinessException {
		setAttributeName(d.getAttributeName());
		setLabel(d.getLabel());
		setDescription(d.getDescription());
	}

	@Override
	protected void validate() throws ValidationException {
		// TODO Auto-generated method stub

	}

	@Override
	protected Class<AttributeTypeDAO> getDAOClass() {
		return AttributeTypeDAO.class;
	}

	public String getAttributeName() {
		return attributeName;
	}

	public void setAttributeName(String attributeName) {
		this.attributeName = attributeName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

}
